package edu.univercidade.tcc.server.model;

import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;

import com.google.common.base.Joiner;

import edu.univercidade.tcc.server.validator.WorkflowOldStatusNotEqualsNewStatus;

@RooJavaBean
@RooToString
@RooEntity(finders = { "findWorkflowsByOldIssueStatus" })
@WorkflowOldStatusNotEqualsNewStatus
public class Workflow {

	@NotNull
	@ManyToOne
	@JoinColumn(name = "tracker_id")
	private Tracker tracker;

	@NotNull
	@ManyToOne
	@JoinColumn(name = "old_status_id")
	private IssueStatus oldIssueStatus;

	@NotNull
	@ManyToOne
	@JoinColumn(name = "new_status_id")
	private IssueStatus newIssueStatus;

	@NotNull
	@ManyToOne
	@JoinColumn(name = "role_id")
	private ProjectRole projectRole;

	@Override
	public String toString() {
		return Joiner.on("=>").join(newIssueStatus, oldIssueStatus);
	}

}
